package com.hr.param;

import com.hr.pojo.User;
import jdk.internal.org.objectweb.asm.tree.analysis.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@ResponseBody
@RequestMapping("param")
public class ParamController {

    @GetMapping("data")
    public String data(String name,Integer age){
        System.out.println("name = " + name + ", age = " + age);
        return "name = " + name + ", age = " + age;
    }

    @GetMapping("data1")
    public String data1(@RequestParam(value = "account") String username, @RequestParam(required = false,defaultValue = "1") Integer page){
        //@RequestParam(value = "account") 指定接收的参数 account
        //@RequestParam(required = false,defaultValue = "1") 不指定参数
        System.out.println("username = " + username + ", page = " + page);
        return "username = " + username + ", page = " + page;
    }

    @GetMapping("data2")
    public String data2(@RequestParam List<String> hbs){
        System.out.println("hbs = " + hbs);
        return "hbs = " + hbs;
    }

    @GetMapping("data3")
    public String data3(U   ser user){
        System.out.println("user = " + user);
        return user.toString();
    }

}
